<template>
  <view class="container">
    <!-- 顶部Tab -->
    <view class="tab-bar">
      <view 
        class="tab-item" 
        v-for="tab in tabs" 
        :key="tab.id"
        :class="{'active': currentTab === tab.id}"
        @tap="switchTab(tab.id)"
      >
        <text>{{tab.name}}</text>
      </view>
    </view>

    <!-- 筛选区域 -->
    <view class="filter-section">
      <view class="filter-item">
        <picker mode="date" @change="onDateChange">
          <view class="picker">
            <text>{{selectedDate || '选择日期'}}</text>
            <text class="iconfont">&#xe6e5;</text>
          </view>
        </picker>
      </view>
      <view class="filter-item">
        <picker :range="statusList" @change="onStatusChange">
          <view class="picker">
            <text>{{selectedStatus || '订单状态'}}</text>
            <text class="iconfont">&#xe6e1;</text>
          </view>
        </picker>
      </view>
      <view class="filter-item">
        <picker :range="customerList" @change="onCustomerChange">
          <view class="picker">
            <text>{{selectedCustomer || '选择客户'}}</text>
            <text class="iconfont">&#xe6e1;</text>
          </view>
        </picker>
      </view>
    </view>

    <!-- 订单列表 -->
    <view class="order-list">
      <view class="order-item" v-for="order in orders" :key="order.id">
        <view class="order-header">
          <text class="order-no">订单号：{{order.orderNo}}</text>
          <text class="order-status" :class="order.status">{{order.statusText}}</text>
        </view>
        <view class="order-content">
          <view class="customer-info">
            <text class="label">客户名称：</text>
            <text>{{order.customerName}}</text>
          </view>
          <view class="goods-info">
            <text class="label">货品信息：</text>
            <text>{{order.goodsInfo}}</text>
          </view>
          <view class="delivery-info">
            <text class="label">配送时间：</text>
            <text>{{order.deliveryTime}}</text>
          </view>
        </view>
        <view class="order-footer">
          <text class="amount">¥{{order.amount}}</text>
          <view class="action-buttons">
            <button class="btn" @tap="handleDetail(order)">详情</button>
            <button class="btn primary" @tap="handleProcess(order)">处理</button>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<style lang="scss">
.container {
  background: #F5F7FA;
  min-height: 100vh;
}

.tab-bar {
  display: flex;
  background: #fff;
  padding: 20rpx 30rpx;
  position: sticky;
  top: 0;
  z-index: 100;
  
  .tab-item {
    flex: 1;
    text-align: center;
    padding: 20rpx 0;
    position: relative;
    
    &.active {
      color: #3B4B98;
      font-weight: bold;
      
      &::after {
        content: '';
        position: absolute;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 40rpx;
        height: 4rpx;
        background: #3B4B98;
        border-radius: 2rpx;
      }
    }
  }
}

.filter-section {
  display: flex;
  padding: 20rpx;
  background: #fff;
  margin-bottom: 20rpx;
  
  .filter-item {
    flex: 1;
    padding: 0 10rpx;
    
    .picker {
      background: #F5F7FA;
      padding: 15rpx 20rpx;
      border-radius: 8rpx;
      display: flex;
      justify-content: space-between;
      align-items: center;
      font-size: 24rpx;
    }
  }
}

.order-list {
  padding: 20rpx;
  
  .order-item {
    background: #fff;
    border-radius: 16rpx;
    padding: 30rpx;
    margin-bottom: 20rpx;
    
    .order-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20rpx;
      
      .order-status {
        padding: 4rpx 12rpx;
        border-radius: 4rpx;
        font-size: 24rpx;
        
        &.pending {
          color: #ff9800;
          background: #fff3e0;
        }
        
        &.processing {
          color: #2196f3;
          background: #e3f2fd;
        }
        
        &.completed {
          color: #4caf50;
          background: #e8f5e9;
        }
      }
    }
    
    .order-content {
      font-size: 28rpx;
      line-height: 1.8;
      
      .label {
        color: #666;
      }
    }
    
    .order-footer {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 20rpx;
      padding-top: 20rpx;
      border-top: 2rpx solid #f5f5f5;
      
      .amount {
        font-size: 32rpx;
        font-weight: bold;
        color: #ff5722;
      }
      
      .action-buttons {
        display: flex;
        gap: 20rpx;
        
        .btn {
          padding: 10rpx 30rpx;
          border-radius: 30rpx;
          font-size: 24rpx;
          
          &.primary {
            background: #3B4B98;
            color: #fff;
          }
        }
      }
    }
  }
}
</style>